﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithm.Interview_Easy_0306_AnimalShelf
{
    class MainProject
    {
        static void Main(string[] args)
        {
            AnimalShelf animalShelf = new AnimalShelf();
            animalShelf.Enqueue(new int[] { 0,1});
            animalShelf.Enqueue(new int[] { 1,0});
            animalShelf.DequeueCat();
            animalShelf.DequeueDog();
            animalShelf.DequeueAny();
            //Console.WriteLine(TimeRequiredToBuy(new int[] { 84, 49, 5, 24, 70, 77, 87, 8 }, 3));
            Console.ReadKey();
        }
    }
    public class AnimalShelf
    {
        private List<int[]> m_List;
        public AnimalShelf()
        {
            m_List = new List<int[]>();
        }

        public void Enqueue(int[] animal)
        {
            m_List.Add(animal);
        }

        public int[] DequeueAny()
        {
            if (m_List.Count > 0)
            {
                int[] res = m_List[0];
                m_List.RemoveAt(0);
                return res;
            }
            return new int[] { -1, -1 };
        }

        public int[] DequeueDog()
        {
            int[] res = null;
            int index = -1;
            for (int i = 0; i < m_List.Count; i++)
            {
                if (m_List[i][1] == 1)
                {
                    res = m_List[i];
                    index = i;
                    break;
                }
            }
            if (res!=null)
            {
                m_List.RemoveAt(index);
                return res;
            }
            return new int[] { -1, -1 };
        }

        public int[] DequeueCat()
        {
            int[] res = null;
            int index = -1;
            for (int i = 0; i < m_List.Count; i++)
            {
                if (m_List[i][1] == 0)
                {
                    res = m_List[i];
                    index = i;
                    break;
                }
            }
            if (res != null)
            {
                m_List.RemoveAt(index);
                return res;
            }
            return new int[] { -1, -1 };
        }
    }
}
